<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>Interactive Showroom</title>
    <style>
        :root {
            --bg: #f4f6f9;
            --text: #333;
            --card: white;
            --header: linear-gradient(to right, #4facfe, #00f2fe);
            --shadow: rgba(0, 0, 0, 0.05);
        }

        body.dark {
            --bg: #121212;
            --text: #ddd;
            --card: #1e1e1e;
            --header: linear-gradient(to right, #222, #444);
            --shadow: rgba(255, 255, 255, 0.05);
        }

        body {
            font-family: 'Segoe UI', sans-serif;
            margin: 0;
            padding: 0;
            background: var(--bg);
            color: var(--text);
            transition: background 0.3s, color 0.3s;
        }

        header {
            background: var(--header);
            color: white;
            padding: 2rem;
            text-align: center;
        }

        section {
            padding: 2rem;
            margin: 1rem auto;
            max-width: 800px;
            background: var(--card);
            border-radius: 10px;
            box-shadow: 0 4px 12px var(--shadow);
        }

        h2 { margin-top: 0; }

        .fade-in-up {
            opacity: 0;
            transform: translateY(20px);
            transition: opacity 0.8s ease, transform 0.8s ease;
        }

        .fade-in-up.visible {
            opacity: 1;
            transform: translateY(0);
        }

        input, select, textarea {
            padding: 0.5rem;
            margin: 0.5rem 0;
            width: 100%;
            border: 1px solid #ccc;
            border-radius: 6px;
            transition: box-shadow 0.3s, border 0.3s;
            background: var(--card);
            color: var(--text);
        }

        input:focus, select:focus, textarea:focus {
            outline: none;
            border-color: #007BFF;
            box-shadow: 0 0 8px rgba(0,123,255,0.2);
        }

        button {
            padding: 0.6rem 1.2rem;
            background-color: #007BFF;
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            transition: transform 0.2s ease;
        }

        button:active { transform: scale(0.95); }

        label { display: block; margin-top: 1rem; }

        .toggle {
            position: relative;
            display: inline-block;
            width: 50px;
            height: 26px;
        }

        .toggle input { opacity: 0; width: 0; height: 0; }

        .slider {
            position: absolute;
            cursor: pointer;
            top: 0; left: 0;
            right: 0; bottom: 0;
            background-color: #ccc;
            border-radius: 26px;
            transition: background-color 0.3s;
        }

        .slider::before {
            content: "";
            position: absolute;
            height: 22px; width: 22px;
            left: 2px; bottom: 2px;
            background-color: white;
            border-radius: 50%;
            transition: transform 0.3s;
        }

        .toggle input:checked + .slider {
            background-color: #4caf50;
        }

        .toggle input:checked + .slider::before {
            transform: translateX(24px);
        }

        .draggable-list {
            list-style: none;
            padding: 0;
        }

        .draggable-list li {
            background: #e0e0e0;
            padding: 10px 15px;
            margin: 8px 0;
            border-radius: 6px;
            cursor: move;
            user-select: none;
            transition: background 0.2s;
        }

        .draggable-list li.dragging {
            opacity: 0.5;
        }

        footer {
            text-align: center;
            padding: 1rem;
            font-size: 0.9rem;
            color: #777;
        }
    </style>
</head>
<body>

<header id="pageHeader" data-testid="pageHeader" class="header-main" data-role="header" data-component="site-header">
    <h1>🎨 Interactive Showroom</h1>
    <p>Now with Drag & Drop and Dark Mode</p>
</header>

<section id="userInfoSection" data-testid="userInfoSection" class="fade-in-up section section-user-info" data-role="section" data-component="user-info-section">
    <h2>📝 User Information</h2>
    <label for="userNameInput">Name: <input type="text" id="userNameInput" data-testid="userNameInput" class="input input-name" placeholder="Enter your name" data-role="input" data-component="name-input" aria-label="Enter your name" /></label>
    <label for="userEmailInput">Email: <input type="email" id="userEmailInput" data-testid="userEmailInput" class="input input-email" placeholder="Enter your email" data-role="input" data-component="email-input" aria-label="Enter your email" /></label>
    <label for="userComment">Comment: <textarea id="userComment" data-testid="userComment" class="textarea textarea-comment" placeholder="Leave your message" data-role="textarea" data-component="comment-textarea" aria-label="Enter your comment"></textarea></label>
    <button id="submitUserInfoButton" data-testid="submitUserInfoButton" class="btn btn-submit-user" onclick="alert('Form Submitted!')" data-role="button" data-component="submit-user-button" data-action="submit-user-info" aria-label="Submit user information">Submit</button>
</section>

<section id="appearanceSection" data-testid="appearanceSection" class="fade-in-up section section-appearance" data-role="section" data-component="appearance-section">
    <h2>🌓 Appearance</h2>
    <label for="darkToggleWrapper">
        Dark Mode:
        <span class="toggle" id="darkToggleWrapper" data-testid="darkToggleWrapper" data-role="toggle" data-component="dark-mode-toggle">
        <input type="checkbox" id="darkToggle" data-testid="darkToggle" class="checkbox checkbox-dark-mode" data-role="checkbox" data-component="dark-mode-checkbox" data-action="toggle-dark-mode" aria-label="Toggle dark mode">
        <span class="slider" aria-hidden="true"></span>
      </span>
    </label>
</section>

<section id="dragDropSection" data-testid="dragDropSection" class="fade-in-up section section-drag-drop" data-role="section" data-component="drag-drop-section">
    <h2>📋 Drag & Drop List</h2>
    <p>Reorder the items below:</p>
    <ul class="draggable-list" id="sortableList" data-testid="sortableList" data-role="list" data-component="sortable-list" aria-label="Sortable task list">
        <li draggable="true" class="draggable-item" id="taskItemA" data-testid="taskItemA" data-role="listitem" data-component="drag-item" data-action="drag-item" data-order="1" aria-grabbed="false">🟢 Task A</li>
        <li draggable="true" class="draggable-item" id="taskItemB" data-testid="taskItemB" data-role="listitem" data-component="drag-item" data-action="drag-item" data-order="2" aria-grabbed="false">🔵 Task B</li>
        <li draggable="true" class="draggable-item" id="taskItemC" data-testid="taskItemC" data-role="listitem" data-component="drag-item" data-action="drag-item" data-order="3" aria-grabbed="false">🟣 Task C</li>
        <li draggable="true" class="draggable-item" id="taskItemD" data-testid="taskItemD" data-role="listitem" data-component="drag-item" data-action="drag-item" data-order="4" aria-grabbed="false">🟠 Task D</li>
    </ul>
</section>

<footer id="pageFooter" data-testid="pageFooter" class="footer-main" data-role="footer" data-component="site-footer">© 2025 Interactive Showroom by ChatGPT</footer>

<script>
    // Animate on scroll
    const observer = new IntersectionObserver((entries) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) entry.target.classList.add('visible');
        });
    }, { threshold: 0.1 });

    document.querySelectorAll('.fade-in-up').forEach(el => observer.observe(el));

    // Dark mode toggle
    document.getElementById('darkToggle').addEventListener('change', (e) => {
        document.body.classList.toggle('dark', e.target.checked);
    });

    // Drag and drop
    const list = document.getElementById('sortableList');
    let draggingEl;

    list.addEventListener('dragstart', (e) => {
        draggingEl = e.target;
        e.target.classList.add('dragging');
    });

    list.addEventListener('dragend', (e) => {
        e.target.classList.remove('dragging');
        draggingEl = null;
    });

    list.addEventListener('dragover', (e) => {
        e.preventDefault();
        const afterEl = getDragAfterElement(list, e.clientY);
        if (afterEl == null) {
            list.appendChild(draggingEl);
        } else {
            list.insertBefore(draggingEl, afterEl);
        }
    });

    function getDragAfterElement(container, y) {
        const els = [...container.querySelectorAll('li:not(.dragging)')];
        return els.reduce((closest, child) => {
            const box = child.getBoundingClientRect();
            const offset = y - box.top - box.height / 2;
            if (offset < 0 && offset > closest.offset) {
                return { offset: offset, element: child };
            } else {
                return closest;
            }
        }, { offset: Number.NEGATIVE_INFINITY }).element;
    }

    // Enhance drag & drop aria
    const dList = document.getElementById('sortableList');
    if (dList) {
        dList.addEventListener('dragstart', e => { if (e.target.matches('li[draggable]')) e.target.setAttribute('aria-grabbed','true'); });
        dList.addEventListener('dragend', e => { if (e.target.matches('li[draggable]')) e.target.setAttribute('aria-grabbed','false'); });
    }
</script>
</body>
</html>
